package com.wtwd.campus.utils;

import com.wtwd.campus.common.RespCode;
import com.wtwd.campus.common.RespCodeEntity;
import com.wtwd.campus.service.IRMFeignClientService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class AttendanceCommandUtils {
    private static final Logger logger= LoggerFactory.getLogger(AttendanceCommandUtils.class);

    @Autowired
    private IRMFeignClientService irmFeignClientService;

    /**
     * 时间校准指令下发
     * @param productNo
     */
    public boolean sendTimeAdjusting(String productNo){
        RespCodeEntity respCodeEntity = irmFeignClientService.sendTimeAdjusting(productNo);
        boolean result = respCodeEntity.getCode() == RespCode.SUCCESS.getCode();
        logger.info("指令【考勤机时间检验】发送到RocketMQ : {}", result ? "成功" : "失败");
        return result;
    }

    /**
     * 打卡数据上报的回复
     * @param serialNo
     */
    public boolean sendDataReply(String serialNo,String productNo){
        RespCodeEntity respCodeEntity = irmFeignClientService.sendDataReply(serialNo,productNo);
        boolean result = respCodeEntity.getCode() == RespCode.SUCCESS.getCode();
        logger.info("指令【考勤机打卡数据上报指令回复】发送到RocketMQ : {}", result ? "成功" : "失败");
        return result;
    }

}
